This week assignment is to implement a network using microcontrollers demonstrating the concepts in networking such as identity and parallel processing capability.
I2C requires a mere two wires, like asynchronous serial, but those two wires can support up to 1008 slave devices. Also, unlike SPI, I2C can support a multi-master system, allowing more than one master to communicate with all devices on the bus (although the master devices can't talk to each other over the bus and must take turns using the bus lines). Data rates fall between asynchronous serial and SPI; most I2C devices can communicate at 100kHz or 400kHz. There is some overhead with I2C; for every 8 bits of data to be sent, one extra bit of meta data (the “ACK/NACK” bit, which we’ll discuss later) must be transmitted. The hardware required to implement I2C is more complex than SPI, but less than asynchronous serial. It can be fairly trivially implemented in software.
To learn the basic of networking i used the Neil's serial Communication examples, and redesignned them to carry a button and an LED. This board uses a ATtiny45. Connections for FTDI to do serial communication is done separately.
There are two board here, the bridge and the node. The bridge connects the computer to the network of microcontrollers through ftdi cable. The node is connected to the bridge through 4 pin connector with Vcc and GND common from the brdige.
The milled board using SRM 20 and stuffed board are shown below
After soldering the milled bridge board it was not working. I checked all the connections, short circuits but nothing resolved my problem. Later i releaized that ATtiny45 was not working in the board. Now i de-soldered this ATtiny45 to solder the new one.
In Neil's code I made the following changes.
Changed the LED pin
For bridge
#define led_pin (1 << PB0)
For Node
#define led_pin (1 << PB2)
Changed the rx, tx pin
#define serial_pin_in (1 << PB3) //to tx
#define serial_pin_out (1 << PB4) //to rx
I uploaded the program with node id hardcoded to identify wach board.
For bridge
#define node_id '0'
For Node
#define node_id '1'
When i tried the serial communication it was observed that output was not following the input.So to debug this i made a chnage in the code
#define bit_delay_time 102 // bit delay for 9600 with overhead
Program Explanation
When i was sending 0 and 1 the board reacted to it and sending message which board is operation either node 1 or node 2
While i was working on Serial communication ,the node 2 board was not transmitting any data. Later on debugging it was found that txpin was having lose connection